import { User } from 'my-web-core/auth';
import React from 'react';
import { Route } from 'react-router-dom';

import { getGuardedElement } from '@/shared/components/RouterHelper';

const rootPath: string = '/authentication';
const loginPath: string = 'login';

const Login = React.lazy(() => import('@/features/authentication/components/Login'));

function getAuthenticationRoute(currentUser: User | null) {
  return (
    <Route path={rootPath}>
      <Route
        path={loginPath}
        element={getGuardedElement(`${rootPath}/${loginPath}`, <Login />, currentUser)}
      />
    </Route>
  );
}

export default getAuthenticationRoute;
